package com.flavors.ifly.hencoderplus;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

/**
 * 画仪表盘
 */
public class Dashboard extends View {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    //底部不画的剩余角度
    public static final int ANGLE = 120;
    //半径
    public static final float radius = Utils.dp2Px(150);

    public Dashboard(Context context) {
        super(context);
    }

    public Dashboard(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Dashboard(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        paint.setColor(Color.RED);
        paint.setStrokeWidth(10);//粗细
        paint.setStyle(Paint.Style.STROKE);//不填充
        //这个参考视频就知道参数意思了 false不闭合
        canvas.drawArc(getWidth() / 2 - radius, getHeight() / 2 - radius, getWidth() / 2 + radius, getHeight() / 2 + radius,
                90 + ANGLE / 2, 360 - ANGLE, false, paint);//super.drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
    }


}
